<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta http-equiv="Cache-control" content="no-cache">

	<%-- CSS Style Declarations --%>
	<link rel ="stylesheet" type="text/css" href="stylesheets/style.css" ></link>
	
		<%-- Java imports --%>
	<%@ page import="java.io.*" %>
	<%@ page import="java.util.*" %>
	<%@ page import="flashcardtest.FlashCardSet" %>
	<%@ page import="flashcardtest.FlashCard" %>
	<%@ page import="flashcardtest.FlashCardCore" %>
	<%@ page import="com.google.appengine.api.datastore.DatastoreService" %>
	<%@ page import="com.google.appengine.api.datastore.DatastoreServiceFactory" %>
	<%@ page import="com.google.appengine.api.datastore.Entity" %>
	<%@ page import="com.google.appengine.api.datastore.PreparedQuery" %>
	<%@ page import="com.google.appengine.api.datastore.Query" %>
	<%@ page import="com.google.appengine.api.users.UserService" %>
	<%@ page import="com.google.appengine.api.users.UserServiceFactory" %>

	<%-- Get reference to Java Objects --%>
	<% 	FlashCardCore core = (FlashCardCore) request.getSession().getAttribute("core");
		if (core == null) {
			core = new FlashCardCore();
			request.getSession().setAttribute("core", core);
		}
	    %>
	<%-- Detect User Logged In --%>
	<%
		if (!core.loggedIn()){
			response.sendRedirect("/login.jsp");
		}
	  	%>

	<title>Quiz-O-Matic</title>
</head>

<body>

<div id="center-column">

<!-- Header -->
<div id="header">
</div> <!-- /header -->

<!-- User name -->
<div id="user_name">
	<% out.println( core.getUserName() + 
			" (<a href=\"" + core.getLogoutURL(request) +
			"\">sign out</a>)"); %>
</div> <!-- /user name -->

<!-- Page Title -->
<div style="
	position: absolute;
	top: 90px;
	width:600px;
	text-align:center;
	font-size:50px;
	">
	Quiz-O-Matic
</div> <!-- /page title -->
	
<!-- Page Form -->	
<form action="setup" method="post">

<!-- Start Button -->	
<div style="
	position:absolute;
	top: 170px;
	width: 600px;
	text-align:center;">
	<input
		type="submit"
		class="startbutton"
		name="mode"
		value="Start Quiz"
		title="">
</div> <!-- Start Button -->
	
	
<!-- Select Dictionary -->
<div style="
	position:absolute;
	top: 300px;
	left: 0px;
	width:600px;
	text-align:center;">
	
	Dictionary:		
	<select name="set">
	<% 
		ArrayList<String> sets = core.getSets();
		
		Iterator itr = sets.iterator();
		while (itr.hasNext()) {
			String selected = "";
			String set = (String)itr.next();
			String currentAlbum = core.getSetName(); // gets the name of the currently selected album
			if (set.equals(currentAlbum)) {selected = " selected=\"selected\"";}
			out.println("<option value=\"" + set + "\"" + selected + ">" + set + "</option>");
		}
	%>
	</select> 
	
	
</div> <!-- select dictionary -->

<!-- Other Mode Select -->
<div style="
	position:absolute;
	top: 340px;
	width: 600px;
	text-align:center;
	">
	<input
		type="submit"
		class="bigbutton"
		name="mode"
		value="Lookup"
		title="">
	<input
		type="submit"
		class="bigbutton"
		name="mode"
		value="Edit Dictionary"
		title="">
	<input
		type="submit"
		class="bigbutton"
		name="mode"
		value="New Dictionary"
		title="">
	<input
		type="submit"
		class="bigbutton"
		name="mode"
		value="Upload Photo"
		title="">
	<input
		type="submit"
		class="bigbutton"
		name="mode"
		value="Album"
		title="">
		
		
</div> <!-- mode select -->
</form> <!-- page form -->

</div> <!-- center-column -->
</body>
</html>